package com.job.meeting.pojo;


import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;

@Data//注解在类上；提供类所有属性的 getting 和 setting 方法，此外还提供了equals、canEqual、hashCode、toString 方法
@AllArgsConstructor//有参构造器
@NoArgsConstructor//无参构造器
@Table(name = "user")//声明此对象映射到数据库的数据表，通过它可以为实体指定表(talbe)
public class user {
    private int id;
    private String openid;
    private String nickname;
    private String real_name;
    private int sex;
    private String province;
    private String city;
    private String country;
    private String headimgurl;
    private String unionid;
    private int privilege;

    //user的构造函数，输入一个json字段构造一个对应的对象
    public user(String json){
        user u = new Gson().fromJson(json,user.class);
        this.setId(u.getId());
        this.setOpenid((u.getOpenid()));
        this.setNickname(u.getNickname());
        this.setReal_name(u.getReal_name());
        this.setSex(u.getSex());
        this.setProvince(u.getProvince());
        this.setCity(u.getCity());
        this.setCountry(u.getCountry());
        this.setHeadimgurl(u.getHeadimgurl());
        this.setUnionid(u.getUnionid());
        this.setPrivilege(u.getPrivilege());
    }

    //覆写toString函数，返回一个json字段
    public String toString(){
        return "";
    }
}
